<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Mongo_DB Class - Methods - Fuel Documentation</title>
	<link href="../../assets/css/main.css" media="screen" rel="stylesheet" />
	<script type="text/javascript" src="../../assets/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../../assets/js/nav.js"></script>
	<script type="text/javascript" src="../../assets/js/highlight.pack.js"></script>
	<script type="text/javascript">
		$(function() {
			show_nav('classes', '../../');
		});
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
	</script>
</head>
<body>

	<header>
		<h1>Fuel Documentation</h1>
	</header>

	<div id="main-nav"></div>

	<section id="content">
		<h2>Mongo_Db Class Methods</h2>

		<p>
			The Mongo_Db class allowes you to interact with MongoDB databases. While in some cases it's
			simular to interacting with databases like MySQL there are some distinct differences.
		</p>
		
		<p class="note">
			All sorting options (order by and indexes) use -1, false, 'desc' or 'DESC' as <em>DESC</em>. Any other value will be <em>ASC</em>.
		</p>


		<article>
			<h4 id="method_instance">instance($name = 'default')</h4>
			<p>
				The <strong>istance</strong> method returns a new Mongo_Db instance. Use the $name parameter
				to specify which configuration and database to use.
			</p>
			<p class="note">
				By default <strong>$name</strong> is <em>'default'</em> which requires you to have a default configuration in you
				db.php config file. <a href="introduction.html#config">Read more about Mongo_Db configuration.</a>
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>'default'</code></pre></td>
								<td>The name of the config group to use.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>A new Mongo_Db instance</td>
				</tr>
				<tr>
					<th>Throws</th>
					<td>Mongo_DbException, when no config if found for the given instance name.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get the default group
$mongodb = \Mongo_Db::instance();

// Get a custom group
$mongodb = \Mongo_Db::instance('my_group');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_get">get($collection = "")</h4>
			<p>
				The <strong>get</strong> method returns the result from a collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection name.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>A stdClass object containing the result arrays.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

$result = $mongodb->get('users');
foreach($result as $user)
{
	// Do something with $user
}
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_get_where">get_where($collection = "", $where = array(), $limit = 99999)</h4>
			<p>
				The <strong>get_where</strong> method returns the result from a collection. In addition to that you can supply
				an array for conditioning the result and provide a limit.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection name.</td>
							</tr>
							<tr>
								<th><kbd>$where</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of where statements.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>A stdClass object containing the result arrays.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Get the first 10 result where 'active' is "yes"
$result = $mongodb->get_where('users', array(
	'active' => 'yes',
), 10);

foreach($result as $user)
{
	// Do something with $user
}
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_select">select($includes = array(), $excludes = array())</h4>
			<p>
				The <strong>select</strong> method sets which fields to include or which to exclude during the query process.
			</p>
			<p class="note">
				In order to use the exclude array the includes array must be empty.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$includes</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>Array of fields to include</td>
							</tr>
							<tr>
								<th><kbd>$where</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>Array of fields to exclude</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
// Just select these fields
$mongodb->select(array(
	'name',
	'surname',
	'email',
));
$users = $mongodb->get('users');

// Or use the exclude array

$mongodb = \Mongo_Db::instance();
// Just select these fields
$mongodb->select(array(), array(
	'not_this',
	'or_this',
));
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where">where($wheres = array())</h4>
			<p>
				The <strong>where</strong> method sets the 'where is equal to' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$wheres</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of associative array with the field as the key and the value as the search criteria.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance.
$mongodb = \Mongo_Db::instance();

$mongodb->where(array(
	'name' => 'John',
	'surname' => 'Doe,
));

$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_or_where">or_where($wheres = array())</h4>
			<p>
				The <strong>or_where</strong> method sets the 'or where is equal to' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$wheres</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of associative array with the field as the key and the value as the search criteria.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where(array(
	'name' => 'John',
	'surname' => 'Doe,
))->or_where(array(
	'name' => 'Jim',
));
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_where_in">where_in($field = "", $in = array())</h4>
			<p>
				The <strong>where_in</strong> method sets the 'where in' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$in</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of possible values.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_in('name', array(
	'John', 'James', 'Frank', 'Dave',
));
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_in_all">where_in_all($field = "", $in = array())</h4>
			<p>
				The <strong>where_in_all</strong> method sets the 'all where in' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$in</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of possible values.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_in_all('name', array(
	'John', 'James', 'Frank', 'Dave',
));
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_not_in">where_not_in($field = "", $in = array())</h4>
			<p>
				The <strong>where_not_in</strong> method sets the 'where not in' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$in</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of possible values.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_not_in('name', array(
	'John', 'James', 'Frank', 'Dave',
));
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_gt">where_gt($field = "", $x)</h4>
			<p>
				The <strong>where_gt</strong> method sets the 'where greater than' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_gt('age', 12);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_gte">where_gte($field = "", $x)</h4>
			<p>
				The <strong>where_gte</strong> method sets the 'where greater than or equal to' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_gte('age', 18);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_lt">where_lt($field = "", $x)</h4>
			<p>
				The <strong>where_lt</strong> method sets the 'where lower than' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_lt('age', 120);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_lte">where_lte($field = "", $x)</h4>
			<p>
				The <strong>where_lte</strong> method sets the 'where lower than or equal to' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_lt('age', 120);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_between">where_between($field = "", $x)</h4>
			<p>
				The <strong>where_between</strong> method sets the 'where between' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The low value to compare it to.</td>
							</tr>
							<tr>
								<th><kbd>$y</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The high value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_between('age', 10, 20);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_where_between_ne">where_between_ne($field = "", $x)</h4>
			<p>
				The <strong>where_between_ne</strong> method sets the 'where between and not equal to' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The low value to compare it to.</td>
							</tr>
							<tr>
								<th><kbd>$y</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The high value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_between_ne('age', 10, 20);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_ne">where_between_ne($field = "", $x)</h4>
			<p>
				The <strong>where_ne</strong> method sets the 'where not equal to' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>mixed</em></td>
								<td><strong>required</strong></td>
								<td>The low value to compare it to.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->where_ne('name', 'Allerd');
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_like">like($field = '', $value = '', $flags = 'i', $enable_start_wildcard = true, $enable_end_wildcard = true)</h4>
			<p>
				The <strong>like</strong> method a sets a 'like' statement.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$field</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The field to query.</td>
							</tr>
							<tr>
								<th><kbd>$value</kbd></th>
								<td><em>mixed</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The value to compare it to.</td>
							</tr>
							<tr>
								<th><kbd>$flags</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>'i'</code></pre></td>
								<td>
									Allows you to set typical regular expression flags:
									<ul>
										<li>i = case insensitive</li>
										<li>m = multiline</li>
										<li>x = can contain comments</li>
										<li>l = locale</li>
										<li>s = dotall, "." matches everything, including newlines</li>
										<li>u = match unicode</li>
									</ul>
								</td>
							</tr>
							<tr>
								<th><kbd>$enable_start_wildcard</kbd></th>
								<td><em>bool</em></td>
								<td><pre class="php"><code>false</code></pre></td>
								<td>When set to <em>true</em> the beginning of the string must match.</td>
							</tr>
							<tr>
								<th><kbd>$enable_end_wildcard</kbd></th>
								<td><em>bool</em></td>
								<td><pre class="php"><code>false</code></pre></td>
								<td>When set to <em>true</em> the ending of the string must match.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->like('name', 'fran', 'im', true);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_order_by">order_by($fields = array())</h4>
			<p>
				The <strong>order_by</strong> method orders the result.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$fields</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>To set values to descending order, you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be set to 1 (ASC).</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
$mongodb->order_by(array(
	'age' => 'asc',
	'name' => 'desc'
	
));
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_limit">limit($x = 99999)</h4>
			<p>
				The <strong>limit</strong> method limits the number of items fetched.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>number</em></td>
								<td><pre class="php"><code>99999</code></pre></td>
								<td>The number of items to fetch.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
// Get the 10 oldest
$mongodb->order_by(array(
	'age' => 'desc',	
))->limit(10);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_offset">offset($x = 0)</h4>
			<p>
				The <strong>offset</strong> method sets the number of items skip.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$x</kbd></th>
								<td><em>number</em></td>
								<td><pre class="php"><code>0</code></pre></td>
								<td>The number of items to skip.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The currenct Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();
// Get row 10 to 15
$mongodb->order_by(array(
	'age' => 'desc',	
))->limit(5)->offset(10);
$users = $mongodb->get('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_count">count($collection = '')</h4>
			<p>
				The <strong>count</strong> method counts the result.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The number of rows.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Get the amount of users.
$num_users = $mongodb->count('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_insert">insert($collection = '', $insert = array())</h4>
			<p>
				The <strong>insert</strong> method inserts a row into the given collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
							<tr>
								<th><kbd>$insert</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>The values to insert</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The insert id, or <em>false</em> on failure.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Insert a new user
$insert_id = $mongodb->insert('users', array(
	'name' => 'John',
	'surname' => 'Doe',
	'email' => 'dont.em@ilme.com',
));
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_update">update($collection = "", $data = array(), $options = array())</h4>
			<p>
				The <strong>update</strong> method updates a given collection.
			</p>
			<p class="note">
				If you do not set the <em>"multiple"</em> option to <em>true</em> only the first encountered record will be updated.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
							<tr>
								<th><kbd>$data</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>The new values.</td>
							</tr>
							<tr>
								<th><kbd>$options</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>
									Supply optional extra options
									<a target="_blank" href="http://php.net/manual/en/mongocollection.update.php#refsect1-mongocollection.update-parameters">(?)</a>
									to the update command.
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><em>true</em> on success</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Update a user
$bool = $mongodb->where('id', $an_id)->update('users', array(
	'name' => 'John',
	'surname' => 'Doe',
	'email' => 'john@doe.com',
));
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_update_all">update_all($collection = "", $data = array())</h4>
			<p>
				The <strong>update</strong> method updates all records in a given collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
							<tr>
								<th><kbd>$data</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>The new values.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><em>true</em> on success</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Update Spammer's surname.
$bool = $mongodb->where('name', 'Spammer')->update_all('users', array(
	'surname' => 'Don\'t believe us.',
));
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
				
		<article>
			<h4 id="method_delete">delete($collection = "")</h4>
			<p>
				The <strong>delete</strong> method deletes the first record in a given collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><em>true</em> on success</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Delete a user named Spammer
$bool = $mongodb->where('name', 'Spammer')->delete('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_delete_all">delete_all($collection = "")</h4>
			<p>
				The <strong>delete_all</strong> method deletes all records in a given collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><em>true</em> on success</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

// Delete all users named Spammer
$bool = $mongodb->where('name', 'Spammer')->delete_all('users');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_command">command($query = array())</h4>
			<p>
				The <strong>command</strong> method runs a MongoDB command. Find out more about commands at
				<a href="http://www.mongodb.org/display/DOCS/Commands" target="_blank">the MongoDB docs</a>.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$query</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array of command parameters.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The command result</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

$mongodb->command(array(
	'geoNear' => 'buildings',
	'near' => array(53.228482, -0.547847),
	'num' => 10,
	'nearSphere' => true
));
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_add_index">add_index($collection = "", $keys = array(), $options = array())</h4>
			<p>
				The <strong>add_index</strong> method adds an index of the keys in a collection with optional parameters. Read more about the options at
				<a href="http://php.net/manual/en/mongocollection.ensureindex.php#refsect1-mongocollection.ensureindex-parameters" target="_blank">php.net</a>.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
							<tr>
								<th><kbd>$keys</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An associative array with fields and sorting directions.</td>
							</tr>
							<tr>
								<th><kbd>$options</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An array with optional settings.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The current Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

$mongodb->add_index('my_collection', array(
	'first_name' => 'ASC', 
	'last_name' => -1)
, array(
	'unique' => true
));
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_remove_index">remove_index($collection = "", $keys = array())</h4>
			<p>
				The <strong>remove_index</strong> method removes one or more indexes from a collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
							<tr>
								<th><kbd>$keys</kbd></th>
								<td><em>array</em></td>
								<td><pre class="php"><code>array()</code></pre></td>
								<td>An associative array with fields (and sorting directions).</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The current Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

$mongodb->remove_index('my_collection', array(
	'first_name' => 'ASC', 
	'last_name' => -1)
));

// or 

$mongodb->remove_index('first_name');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_remove_all_indexes">remove_all_indexes($collection = "")</h4>
			<p>
				The <strong>remove_index</strong> method removes al indexes from a collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>The current Mongo_Db instance.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

$mongodb->remove_all_indexes('my_collection');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
		<article>
			<h4 id="method_list_indexes">list_indexes($collection = "")</h4>
			<p>
				The <strong>remove_index</strong> method returns an array of index names for this collection.
			</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Type</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$collection</kbd></th>
								<td><em>string</em></td>
								<td><pre class="php"><code>''</code></pre></td>
								<td>The collection (table) to use.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>An array of index names for this collection.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// Get an instance
$mongodb = \Mongo_Db::instance();

$indexes = $mongodb->list_indexes('my_collection');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>
		
	</section>

	<section id="footer">
		<p>
			<a href="http://fuelphp.com">Fuel</a> is released under the MIT license.<br />
			&copy; 2010 - 2011 Fuel Development Team
		</p>
	</section>

</body>
</html>
